home *** CD-ROM | disk | FTP | other *** search
- id requestingImage;
-
- // This method is invoked just before the page is returned
- // to the client. The first time the page is requested, requestingImage is NO
- // so the image isn't put in the response. The browser receives the HTML page
- // and then requests the image from the server, which invokes the getImage method.
-
- - willGenerateResponse:response inContext:context {
-
- if (requestingImage == YES) {
- [self putImageInResponse:response context:context];
- requestingImage = NO;
- } else {
- // don't put image in response--we're just generating
- // the initial page without the image
- }
- return nil;
- }
-
-
- // This method sets a flag that informs the willGenerateResponse:inContext:
- // method that a request is being made for the image data.
- - getImage {
- requestingImage = YES;
- return self;
- }
-
-
- // This method gets the image data from a file and puts it, along with the
- // proper header, into the http response that is set back to the browser.
-
- - putImageInResponse:response context:context {
- id theData;
- id theFile;
- id pageName;
- id header = @{"content-type" = "image/gif";};
-
- pageName = [context pageName];
- theFile = [WOApp pathForResource:@"PoweredByNEXTSTEP"
- ofType:@"gif"
- inComponentWithName:pageName];
- if (theFile) {
- theData = [NSData dataWithContentsOfFile:theFile];
- [response setContent:theData];
- [response setHeaders:header];
- }
- return nil;
- }
-
-